<template>
    <div style="height: 50px;">
        <el-button @click="AddDeli()">保存</el-button>
    </div>

    <h2 style="text-align: center;">发货确认</h2>
        <table border="1"
            style="border-collapse: collapse; width: 100%; height: 30px;margin-top: 30px;margin-bottom: 30px;color:black">
            <tr>
                <td :colspan="8" style="height: 50px; font-size: 20px"> 发货信息</td>
            </tr>
            <tr style="height: 70px;">
                <td>
                    <el-form ref="ruleFormRef" :model="form" label-width="120px" class="demo-ruleForm" size="small"
                        style="margin-top: 10px;">
                        <el-row>
                            <el-col :span="6">
                                <el-form-item label="单据编号：" prop="deliveryConfirmationNumber">
                                    <el-input style="width:200px ;" size="large" placeholder="保存后自动生成" disabled/>
                                </el-form-item>
                            </el-col>
                            <el-col :span="5">
                                <el-form-item label="关联发货申请：" prop="sprTopic">
                                    <el-input v-model="form.sprTopic" style="width:200px ;"
                                        size="large" />
                                </el-form-item>
                            </el-col>
                            <el-col :span="5">
                                <el-form-item label="应发日期：" >
                                    <el-date-picker
                                        v-model="form.sraDueDate"
                                        type="date"
                                        style="width: 200px;"
                                        placeholder="请选择应发日期"
                                        format="YYYY/MM/DD"
                                        value-format="YYYY-MM-DD"
                                    />
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item label="实发日期：" >
                                    <el-date-picker
                                        v-model="form.ssraDueDate"
                                        type="date"
                                        style="width: 200px;"
                                        placeholder="请选择实发日期"
                                        format="YYYY/MM/DD"
                                        value-format="YYYY-MM-DD"
                                    />
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="6">
                                <el-form-item label="发货人：" prop="sraApplicant">
                                    <el-input v-model="form.sraApplicant" style="width:200px ;" size="large"/>
                                </el-form-item>
                            </el-col>
                            <el-col :span="5">
                                <el-form-item label="发货方式：" prop="faHuoType">
                                    <el-select v-model="form.faHuoType" style="width: 200px;" size="large" clearable >
                                        <el-option value="">请选择</el-option>
                                        <el-option value="整车运输">整车运输</el-option>
                                        <el-option value="邮政EMS">邮政EMS</el-option>
                                        <el-option value="航空快运">航空快运</el-option>
                                        <el-option value="中铁快运">中铁快运</el-option>
                                        <el-option value="货站托运">货站托运</el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                            <el-col :span="5">
                                <el-form-item label="快递公司：" prop="gongSi">
                                    <el-select v-model=form.gongSi style="width: 200px;" size="large" clearable >
                                        <el-option value="">请选择</el-option>
                                        <el-option value="顺丰快递">顺丰快递</el-option>
                                        <el-option value="邮政EMS">邮政EMS</el-option>
                                        <el-option value="中通速运">中通速运</el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                            <el-col :span="5">
                                <el-form-item label="快递单号：" prop="kuaiDiNumber">
                                    <el-input v-model="form.kuaiDiNumber" style="width:200px ;" size="large" />
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="8">
                                <el-form-item label="快递费用(元)：" prop="pricesss">
                                    <el-input v-model="form.pricesss" style="width:200px ;" size="large" />
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="21">
                                <el-form-item label="发货备注：" prop="pricesss">
                                    <el-input
                                        v-model="form.remarks"
                                        style="width: 100%"
                                        :rows="2"
                                        type="textarea"
                                    />
                                </el-form-item>
                            </el-col>
                        </el-row>
                    </el-form>
                </td>
            </tr>
        </table>






</template>
    
<script setup lang='ts'>
import axios from 'axios'
import { ElMessage, ElMessageBox } from 'element-plus';
import { ref, reactive, onMounted, computed, watch } from 'vue'
import { useRouter ,useRoute} from 'vue-router';
const router = useRouter();
const route = useRoute();
import http from '../../../http.js'

onMounted(() => {
    BackFill();//发货反填
})

const form = reactive({
    "addName": "卢芳",
    "addTime": "2025-01-01",
    "updName": "string",
    "updTime": "2025-01-01T12:28:09.171Z",
    "delName": "string",
    "delTime": "2025-01-01T12:28:09.171Z",
    "isDel":false,
    "office_Id": "1",
    "user_Id": 1,
    "deliveryConfirmationID": 0,
    "deliveryConfirmationNumber": "11111",
    "sprTopic": "",
    "sraDueDate": "",
    "ssraDueDate": "",
    "sraApplicant": "",
    "faHuoType": "",
    "gongSi": "",
    "kuaiDiNumber": "",
    "pricesss": '',
    "remarks": "",
    "vName": "",
    "shippRequestAppId": '',
    "state":2
})


//反填
const BackFill = () => {
    axios.get(http.zblnb + "/erpck/api/Ship/BackFillSHip?shipid=" + route.query.id).then(res => {
        console.log(res.data.data);
        var d = res.data.data;
        form.sraDueDate=d.sraDueDate
        form.sprTopic = d.sprTopic
        form.sraApplicant = d.sraApplicant
        form.vName = d.name,
        form.shippRequestAppId = d.shippRequestAppId
        form.kuaiDiNumber = d.sraNumber
        form.faHuoType = d.sraShipmentsType
        form.gongSi=d.sraCourierCompanie
        form.pricesss=d.sraCourierCharges
    }).catch(err => {
        console.log(err);
    })
}

//保存
const AddDeli = () => {
    console.log(form);
    
    axios.post(http.zblnb +'/erpck/api/Ship/AddDeliveryConfirmation',form)
    .then(res => {
        if (res.data.data > 0) {
            ElMessage.success('添加成功')
            router.push('/ShowShipList')
        }    
        else {
            ElMessage.error('添加失败')
            return
        }
    })
}

    
</script>
    
<style>
    
</style>